//============================================================================
//	警告: 这个文件是使用2009-8-28 17:56:54建立的IBatisNetGen.DaoImpl.cst生成的.
//				重新生成时,原先手动做的修改将会丢失.
//============================================================================
using System;
using System.Collections.Generic;
using System.Text;
using IBatisNet.DataMapper;
using Bino.ExamOnline.Components.Entitys;
using Bino.ExamOnline.Components.Interface;
using Bino.Common.TextLib;

namespace Bino.ExamOnline.DataProvider 
{	
    /// <summary>实现<see cref="ITeacherDao"/>接口.</summary>
    public class TeacherDataProvider : DataProviderBase, ITeacherDao 
	{
		/// <summary>实现 <see cref="ITeacherDao.GetTeachersCount"/></summary>
		public int GetTeachersCount() {
			string statementId = "Teacher.GetTeachersCount";
			int result = ExecuteQueryForObject<int>(statementId, null);
			return result;
		}

		/// <summary>实现 <see cref="ITeacherDao.GetTeacher"/></summary>
		public Teacher GetTeacher(Int32 iD) 
		{
			string statementId = "Teacher.GetTeacher";
			Teacher result = ExecuteQueryForObject<Teacher>(statementId, iD);
			return result;
		}


		/// <summary>实现 <see cref="ITeacherDao.GetAllTeachers"/></summary>
		public IList<Teacher> GetAllTeachers() 
		{
			string statementId = "Teacher.GetAllTeachers";
			IList<Teacher> results = ExecuteQueryForList<Teacher>(statementId, null);
			return results;
		}

		/// <summary>实现 <see cref="ITeacherDao.GetAllTeachersWithOutLob"/></summary>
		public IList<Teacher> GetAllTeachersWithOutLob()
		{
			string statementId = "Teacher.GetAllTeachersWithOutLob";
			IList<Teacher> results = ExecuteQueryForList<Teacher>(statementId, null);
			return results;
		}
	
		/// <summary>实现 <see cref="ITeacherDao.CreateTeacher"/></summary>
		public void CreateTeacher(Teacher obj)
		{
			if (obj == null) 
				return;
			string statementId = "Teacher.CreateTeacher";
			ExecuteInsert(statementId, obj);
		}

		/// <summary>实现 <see cref="ITeacherDao.UpdateTeacher"/></summary>
		public void UpdateTeacher(Teacher obj) 
		{
            UpdateTeacher(obj, false);
		}

        /// <summary>实现 <see cref="ITeacherDao.UpdateTeacher"/></summary>
        public void UpdateTeacher(Teacher obj,bool isUpdatePassword)
        {
            if (obj == null)
                return;
            string statementId;
            if (isUpdatePassword)
                statementId = "Teacher.UpdateTeacher";//同时更新password
            else
                statementId = "Teacher.UpdateTeacherNoPassword";//不更新password
            ExecuteUpdate(statementId, obj);
        }

		/// <summary>实现 <see cref="ITeacherDao.DeleteTeacher"/></summary>
		public void DeleteTeacher(Teacher obj) 
		{
			if (obj == null)
				return;
			string statementId = "Teacher.DeleteTeacher";
			ExecuteDelete(statementId, obj);
		}

		/// <summary>实现 <see cref="ITeacherDao.DeleteTeacherByID"/></summary>
		public int DeleteTeacherByID(Int32 iD) 
		{
			string statementId = "Teacher.DeleteTeacherByID";
            int result = Bino.Common.TextLib.StringHelper.SafeInt(ExecuteDelete(statementId, iD).ToString(), -1);
			return result;
		}		

		/// <summary>实现 <see cref="ITeacherDao.ReloadTeacher"/></summary>
		public void ReloadTeacher(Teacher obj) 
		{
			if (obj == null) 
				return;
			string statementId = "Teacher.GetTeacher";
			ExecuteQueryForObject<Teacher>(statementId, obj, obj);
		}

        /// <summary>
        /// 教师、管理员登录
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="UserPassword"></param>
        /// <returns></returns>
        public int LoginTeacher(String UserName, String UserPassword,int UserType)
        {
            string statementId = "Teacher.LoginTeacher";
            Teacher obj = new Teacher();
            obj.UserName = UserName;
            obj.UserPassword = UserPassword;
            obj.UserType = UserType;
            int result = ExecuteQueryForObject<int>(statementId, obj);
            return result;
        }

	}
}
